import os
import sys

from core.rest_client import RestClient
from common.read_data import data

BASE_PATH = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
sys.path.append(BASE_PATH)

data_file_path = os.path.join(BASE_PATH, "config", "setting.ini")
api_root_url = data.load_ini(data_file_path)["host"]["api_root_url"]


class Dashboard(RestClient):

    def __init__(self, api_root_url, **kwargs):
        super(Dashboard, self).__init__(api_root_url, **kwargs)

    def create(self,**kwargs):
        '''
        创建仪表盘
        '''
        return self.post("/api/dashboard/create", **kwargs)

    def list(self,access_token, **kwargs):
        '''
        获取该文件夹下面的仪表盘
        '''
        return self.get("/api/dashboard/list?access_token={}".format(access_token), **kwargs)

    def info(self, access_token, **kwargs):
        '''
        获取仪表盘信息
        '''
        return self.put("/api/dashboard/info?access_token={}".format(access_token), **kwargs)

    def delete(self, access_token, **kwargs):
        '''
        删除仪表盘
        '''
        return self.put("/api/dashboard/delete?access_token={}".format(access_token), **kwargs)

    def modify(self, access_token, **kwargs):
        '''
        编辑仪表盘
        '''
        return self.put("/api/dashboard/modify?access_token={}".format(access_token), **kwargs)

    def copy(self, access_token, **kwargs):
        '''
        复制仪表盘
        '''
        return self.put("/api/dashboard/copy?access_token={}".format(access_token), **kwargs)


    def move(self, access_token, **kwargs):
        '''
        移动仪表盘
        '''
        return self.put("/api/dashboard/move?access_token={}".format(access_token), **kwargs)



dashboard = Dashboard(api_root_url)
